home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / BBS / EZY120_1.ZIP / STRUCT.ARJ / CLIB.ARJ / UPDSYS.CPP < prev   
Encoding:
C/C++ Source or Header  |  1996-03-09  |  1.4 KB  |  58 lines

  1. #include <ezycom.h>
  2. #include <ezylib.h>
  3. #include <stdio.h>
  4. #include <io.h>
  5. #include <dos.h>
  6. #include <dir.h>
  7. #include <share.h>
  8.  
  9. int GetSysInfo(FILE *&hSysInfo,SysInfoRecord &SysInfo)
  10. {
  11.   char SysInfoPath[MAXPATH];
  12.   int Result;
  13.   sprintf(SysInfoPath,"%sSYSINFO.BBS",SystemPath);
  14.   if ((hSysInfo = _fsopen(SysInfoPath,"rb+",SH_DENYNO)) != NULL) {
  15.     int Count = 0, Status;
  16.     while (((Status = lock(fileno(hSysInfo),0L,(long)sizeof(SysInfo))) != 0) &&
  17.            (Count++ <= 15)) {
  18.       sleep(2); 
  19.     }
  20.  
  21.     if (Status == 0) {
  22.       int Len = fread(&SysInfo,sizeof(SysInfo),1,hSysInfo);
  23.       if (Len == 1) {
  24.         ftime ftimep;
  25.         date  datep;
  26.         getdate(&datep);
  27.         getftime(fileno(hSysInfo),&ftimep);
  28.         if ((datep.da_year  != ftimep.ft_year + 1980) ||
  29.             (datep.da_mon   != ftimep.ft_month) ||
  30.             (datep.da_day != ftimep.ft_day)) {
  31.           SysInfo.NewUsers = 0;
  32.           SysInfo.NewFiles = 0;
  33.           SysInfo.NewMessages = 0;
  34.         }
  35.         Result = TRUE;
  36.       } else {
  37.         fclose(hSysInfo);
  38.         Result = FALSE;
  39.       }
  40.     } else
  41.       Result = FALSE;
  42.   } else
  43.     Result = FALSE;
  44.   return(Result);
  45. }
  46.  
  47. void PutSysInfo(FILE *&hSysInfo,SysInfoRecord &SysInfo)
  48. {
  49.   int Status = unlock(fileno(hSysInfo),0L,(long)sizeof(SysInfo));
  50.   if (Status == 0) {
  51.     fseek(hSysInfo,SEEK_SET,0);
  52.     fwrite(&SysInfo,sizeof(SysInfo),1,hSysInfo);
  53.   }
  54.   fclose(hSysInfo);
  55. }
  56.  
  57.  
  58.